package com.gmail.bogatyr.alexander.client.view;

import com.gmail.bogatyr.alexander.client.presenter.TelephoneBookListPresenter;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.*;

public class TelephoneBookListWidget extends Composite implements TelephoneBookListPresenter.Display {

    private final Panel panel;
    private final Label titleLabel;
    private final Label searchLabel;
    private final TextBox searchField;
    private final Button searchButton;
    private final Label searchErrorLabel;
    private final Label numberLabel;
    private final TextBox numberField;
    private final Label numberErrorLabel;
    private final Label nameLabel;
    private final TextBox nameField;
    private final Label nameErrorLabel;
    private final Button addButton;

    public TelephoneBookListWidget() {
        panel = new FlowPanel();
        initWidget(panel);
        
        titleLabel = new Label("Telephone Book");
        panel.add(titleLabel);
        
        searchLabel = new Label("Search");
        panel.add(searchLabel);
        
        searchField = new TextBox();
        searchField.setMaxLength(64);
        panel.add(searchField);
        
        searchButton= new Button();
        panel.add(searchButton);
        
        searchErrorLabel = new Label();
        panel.add(searchErrorLabel);
        
        numberLabel = new Label("Number");
        panel.add(numberLabel);
        
        numberField = new TextBox();
        numberField.setMaxLength(11);
        numberField.setFocus(true);
        panel.add(numberField);

        numberErrorLabel = new Label();
        panel.add(numberErrorLabel);
        
        nameLabel = new Label("Name");
        panel.add(nameLabel);
        
        nameField = new TextBox();
        nameField.setMaxLength(64);
        panel.add(nameField);

        nameErrorLabel = new Label();
        panel.add(nameErrorLabel);
        
        addButton = new Button();
        panel.add(addButton);
    }

    @Override
    public HasValue<String> getSearchTextField() {
        return searchField;
    }

    @Override
    public HasClickHandlers getSearchButton() {
        return searchButton;
    }

    @Override
    public HasValue<String> getNumberTextField() {
        return numberField;
    }

    @Override
    public HasValue<String> getNameTextField() {
        return nameField;
    }

    @Override
    public HasClickHandlers getAddButton() {
        return addButton;
    }
}
